package org.jeecg.modules.deepseek.pojo;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;
import java.util.Date;

public class Task {

    @Schema(description = "任务ID")
    private String taskId;                // 任务ID

    @Schema(description = "任务名称")
    private String taskName;              // 任务名称

    @Schema(description = "任务类型，例如：数据清洗、报告生成等")
    private String taskType;              // 任务类型

    @Schema(description = "是否异步执行")
    private boolean isAsync;              // 是否异步执行

    @Schema(description = "执行列表，Map格式存储执行方法与参数")
    private Map<String, Object> execList; // 执行列表，Map格式存储执行方法与参数

    @Schema(description = "Cron表达式")
    private String cronExpression;       // Cron表达式

    @Schema(description = "任务状态（如待执行、执行中、已完成、失败、取消）")
    private TaskStatus taskStatus;       // 任务状态

    @Schema(description = "任务优先级")
    private int priority;                // 任务优先级

    @Schema(description = "创建时间")
    private Date createTime;             // 创建时间

    @Schema(description = "最后更新时间")
    private Date lastUpdateTime;         // 最后更新时间

    @Schema(description = "任务开始时间")
    private Date startTime;              // 任务开始时间

    @Schema(description = "任务结束时间")
    private Date endTime;                // 任务结束时间

    @Schema(description = "错误信息（如果有）")
    private String errorMessage;         // 错误信息（如果有）

    // 构造方法、getter 和 setter 方法

    public Task(String taskId, String taskName, String taskType, boolean isAsync,
                Map<String, Object> execList, String cronExpression,
                int priority) {
        this.taskId = taskId;
        this.taskName = taskName;
        this.taskType = taskType;
        this.isAsync = isAsync;
        this.execList = execList;
        this.cronExpression = cronExpression;
        this.priority = priority;
        this.taskStatus = TaskStatus.PENDING; // 默认状态为待执行
        this.createTime = new Date();
        this.lastUpdateTime = new Date();
    }

    // Enum for task status
    public enum TaskStatus {
        @Schema(description = "待执行")
        PENDING,

        @Schema(description = "执行中")
        RUNNING,

        @Schema(description = "已完成")
        COMPLETED,

        @Schema(description = "执行失败")
        FAILED,

        @Schema(description = "已取消")
        CANCELLED
    }

    // Getter and Setter methods
    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getTaskType() {
        return taskType;
    }

    public void setTaskType(String taskType) {
        this.taskType = taskType;
    }

    public boolean isAsync() {
        return isAsync;
    }

    public void setAsync(boolean async) {
        isAsync = async;
    }

    public Map<String, Object> getExecList() {
        return execList;
    }

    public void setExecList(Map<String, Object> execList) {
        this.execList = execList;
    }

    public String getCronExpression() {
        return cronExpression;
    }

    public void setCronExpression(String cronExpression) {
        this.cronExpression = cronExpression;
    }

    public TaskStatus getTaskStatus() {
        return taskStatus;
    }

    public void setTaskStatus(TaskStatus taskStatus) {
        this.taskStatus = taskStatus;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
}
